package a66weding.com.jiehuntong.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.makeramen.roundedimageview.RoundedImageView;

import java.util.List;

import a66weding.com.jiehuntong.R;
import a66weding.com.jiehuntong.beans.ThemeStyles;
import a66weding.com.jiehuntong.common.utils.Utils;
import at.technikum.mti.fancycoverflow.FancyCoverFlow;
import at.technikum.mti.fancycoverflow.FancyCoverFlowAdapter;

/**
 * Created by Administrator on 2016/11/29.
 */
public class MyFancyCoverFlowAdapter extends FancyCoverFlowAdapter {
    List<ThemeStyles.DataBean.TemplateListBean> templateList;
    Context mContext;

    public MyFancyCoverFlowAdapter(List<ThemeStyles.DataBean.TemplateListBean> templateList, Context mContext) {
        this.templateList = templateList;
        this.mContext = mContext;
    }

    @Override
    public View getCoverFlowItem(int position, View reusableView, ViewGroup parent) {
        RoundedImageView img=null;
       // if (img != null) {
            img=(RoundedImageView)reusableView;
      //  }else {
            img=new RoundedImageView(mContext);
            img.setCornerRadius(Utils.dip2px(mContext, 3.3f));
            img.setScaleType(ImageView.ScaleType.CENTER_CROP);
            //这里指定item大小
        img.setLayoutParams(new FancyCoverFlow.LayoutParams(Utils.dip2px(mContext, 182.7f),Utils.dip2px(mContext, 264.7f)));
        img.setBackgroundResource(R.drawable.default_theme);
        //设置数据
        Glide.with(mContext).load( templateList.get(position).getNvc_Thumbnail()).into(img);
        return img;
    }
    @Override
    public int getCount() {
        return templateList.size();
    }

    @Override
    public ThemeStyles.DataBean.TemplateListBean getItem(int position) {
        return templateList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }
}
